#include "bookdata.h"
#include <QDebug>
#include <QMessageBox>
#include <QString>
#include <QDebug>
#include <QMessageBox>
#include <QPushButton>
#include <QList>
#include <QAbstractButton>
#include <QFile>
#include <QTextStream>
#include <QIODevice>

BookData dataArray[100];

//构造函数
BookData::BookData()
{


        isbn = "\0";
        bookTitle = "\0";
        author = "\0";
        publisher = "\0";
        dataAdded = "\0";
        qtyOnHand = "0";
        wholesale = "\0";
        retail = "\0";
        existOrNot = false;
        tex = "0.06";

}
//    QString content = dataArray[i].isbn + '\n' + dataArray[i].bookTitle + '\n' + dataArray[i].author + '\n' + dataArray[i].publisher
//            + '\n' + dataArray[i].dataAdded + '\n' + dataArray[i].qtyOnHand + '\n' + dataArray[i].wholesale + '\n' + dataArray[i].retail;


//将小写转换为大写
void BookData::strUpper(char * str)
{
    while (*str != '\0') {
        *str = *str - 32;
        str++;
    }
}

void BookData::lookUpBook()
{
}

//删除图书
void BookData::removeBook(int subscript)
{
    dataArray[subscript].existOrNot = false;
}

//---------------以下是辅助函数-----------------------
//设置书名
void BookData::setTitle(QString cnt)
{
    bookTitle = cnt;
}

//设置ISBN
void BookData::setISBN(QString cnt)
{
    isbn = cnt;
}

//设置作者
void BookData::setAuthor(QString cnt)
{
    author = cnt;
}

//设置出版社
void BookData::setPub(QString cnt)
{
    publisher = cnt;
}

//设置进书日期
void BookData::setDataAdded(QString cnt)
{
    dataAdded = cnt;
}

//设置库存量
void BookData::setQty(QString cnt)
{
    qtyOnHand = cnt;
}

//设置批发价
void BookData::setWholesale(QString cnt)
{
    wholesale = cnt;
}

//设置零售价
void BookData::setRetail(QString cnt)
{
    retail = cnt;
}

//用不到该函数
bool BookData::isEmpty(int subscript)
{
    if(dataArray[subscript].bookTitle == '\0') return true;
    return false;
}
